package nc.impl.lb.lb_011;

import nc.bs.pub.pf.IBackCheckState3;
import nc.bs.pub.pf.ICheckState3;
import nc.hr.frame.persistence.IPersistenceDAO;
import nc.hr.frame.persistence.PersistenceDAO;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.trade.pub.IBillStatus;

public class MyFlowService implements ICheckState3, IBackCheckState3 {
	
	private IPersistenceDAO persistenceDao=new PersistenceDAO();
	
	@Override
	public void backGoing(AggregatedValueObject vo, String approveId,
			String approveDate, String backNote) throws Exception {
		persistenceDao.executeNoResultSQL(null, "update wa_tm_apply_main set states="+ IBillStatus.CHECKGOING +",approvedate=NULL where pk_tm_apply_main='"+vo.getParentVO().getPrimaryKey()+"'");
	}

	@Override
	public void backNoState(AggregatedValueObject vo, String approveId,
			String approveDate, String backNote) throws Exception {
		persistenceDao.executeNoResultSQL(null, "update wa_tm_apply_main set states="+ IBillStatus.FREE +" ,approvedate=NULL where pk_tm_apply_main='"+vo.getParentVO().getPrimaryKey()+"'");
	}

	@Override
	public boolean checkGoing(AggregatedValueObject vo, String ApproveId,
			String ApproveDate, String checkNote) throws Exception {
		persistenceDao.executeNoResultSQL(null, "update wa_tm_apply_main set states="+ IBillStatus.CHECKGOING +",approvedate='"+ApproveDate+"',approvenote ='"+checkNote+"' where pk_tm_apply_main='"+vo.getParentVO().getPrimaryKey()+"'");
		return true;
	}

	@Override
	public boolean checkNoPass(AggregatedValueObject vo, String ApproveId,
			String ApproveDate, String checkNote) throws Exception {
		persistenceDao.executeNoResultSQL(null, "update wa_tm_apply_main set states="+ IBillStatus.NOPASS +" where pk_tm_apply_main='"+vo.getParentVO().getPrimaryKey()+"'");
		return true;
	}

	@Override
	public boolean checkPass(AggregatedValueObject vo, String ApproveId,
			String ApproveDate, String checkNote) throws Exception {
		persistenceDao.executeNoResultSQL(null, "update wa_tm_apply_main set states="+ IBillStatus.CHECKPASS +",approvedate='"+ApproveDate+"',approvenote ='"+checkNote+"' where pk_tm_apply_main='"+vo.getParentVO().getPrimaryKey()+"'");
		return true;
	}

}
